|
|
|
|
|
|
|
Time in Years: <INPUT Type="text" Name="txtTime" Value="20"><BR>
<INPUT Type="Button" Name="cmdCalculate" Value="Calculate Interest">
</BODY>
</HTML> |
|
|
|
|
|
|
|
|
|
Listing 30.2 uses HTML form elements, which have a different set of events and properties. Note, for example, the use of the Value property instead of the Text property. However, as you will see in an upcoming example, you can also insert controls onto Web pages, which have a more familiar set of properties and events.  |
|
|
|
|
|
|
|
|
|
|
In the sample Web page in Listing 30.2, Internet Explorer knows which event procedure to run because the event procedure is named appropriately. However, you could just as easily specify a different Click event procedure by naming it in the button's HTML: |
|
|
|
|
|
|
|
|
<INPUT Type="Button" Name="myButton" Value="Calculate" OnClick="MyProcedure"> |
|
|
|
|
|
|
|
|
This syntax is useful with images in Web pages. Consider the standard method of creating an image hyperlink: |
|
|
|
|
|
|
|
|
<A HREF="http://www.newsite.com/"> <IMG SRC="myimage.gif"></A> |
|
|
|
|
|
|
|
|
This approach works, but your only option is to jump to a new page. A more versatile method is to specify a Click event in the IMG tag. The Click event procedure could use VBScript code to move to the new site or perform whatever action you wanted: |
|
|
|
|
|
|
|
|
<SCRIPT Language = "VBScript">
<!--
Sub ImageClicked()
Window.Navigate ("http://www.newsite.com/")
End Sub
-->
</SCRIPT>
<IMG SRC="myimage.gif" OnClick="ImageClicked"> |
|
|
|
|
|
|
|
|
One easy way to find out the available events is to use the Script Wizard in Microsoft FrontPage. Simply insert the element you want in FrontPage and bring up the Script Wizard, which is shown in Figure 30.7. |
|
|
|
|
|
|
|
|
In the previous example, you examined the Navigate method of Internet Explorer's Window object. This method causes Internet Explorer to open the specified URL. Another useful function is document.write, which writes HTML to the browser window: |
|
|
|
|
|
|
|
|
<SCRIPT Language = "VBScript">
<!--
document.write "The current date and time is " & Now
-->
</SCRIPT> |
|
|
|
|
|